<template>
    <j-modal
            :title="title"
            :width="width"
            :visible="visible"
            switchFullscreen
            @ok="handleOk"
            @cancel="handleCancel"
            cancelText="关闭">
        <a-table
                ref="table"
                size="middle"
                bordered
                rowKey="id"
                :columns="columns"
                :dataSource="dataSource"
                :pagination="ipagination"
                :loading="loading"
                class="j-table-force-nowrap"
                @change="handleTableChange"
        >
            <template slot="htmlSlot" slot-scope="text">
                <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text">
                <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                <img v-else :src="getImgView(text)" height="25px" alt=""
                     style="width: auto;height: 50px;"/>
            </template>
            <template slot="fileSlot" slot-scope="text">
                <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                <a-button
                        v-else
                        :ghost="true"
                        type="primary"
                        icon="download"
                        size="small"
                        @click="uploadFile(text)"
                >下载
                </a-button>
            </template>
        </a-table>
    </j-modal>

</template>

<script>
    /**
     * create by Jane
     */
    import '@/assets/less/TableExpand.less'
    import { JeecgListMixin } from '@/mixins/JeecgListMixin'

    export default {
        mixins: [JeecgListMixin],
        data() {
            return {
                title: '医废收运记录',
                width: '80%',
                visible: false,
                // 表头
                columns: [
                    {
                        title: '序号',
                        dataIndex: '',
                        key: 'rowIndex',
                        width: 60,
                        align: 'center',
                        customRender: function(t, r, index) {
                            return parseInt(index) + 1
                        }
                    },
                    {
                        title: '废物编码',
                        align: 'center',
                        dataIndex: 'recycleBagCode',
                        customRender: function(text) {
                            return text || ' '
                        }
                    },
                    // {
                    //     title: '机构名称',
                    //     align: 'center',
                    //     dataIndex: 'customerName'
                    // },
                    {
                        title: '废物名称',
                        align: 'center',
                        dataIndex: 'wasteName'
                    },
                    {
                        title: '废物量',
                        align: 'center',
                        dataIndex: 'wasteOriginalValue',
                        scopedSlots: { customRender: 'htmlSlot' },
                        customRender: function(value, row, index) {
                            const obj = {
                                children: < span
                            style = 'font-weight:600;' > { value }
                            {
                                row.priceUnit || ''
                            }
                        <
                            /span>,
                            attrs: {
                            }
                        }
                            return obj
                        }
                    },
                    {
                        title: '提交人',
                        align: 'center',
                        dataIndex: 'submitUserName'
                    },
                    {
                        title: '提交时间',
                        align: 'center',
                        dataIndex: 'createTime'
                    }
                ],
                url: {
                    list: null   // 小彭接口 3.0 : 查询数据列表
                }
            }
        },
        methods: {
            async show(cus, companysId) {
                if(companysId){
                    this.queryParam.companysId = companysId;
                }
                if (cus.customerName) {
                    this.title = `【${cus.customerName}】机构待收运废物`
                } else {
                    this.title = '机构待收运废物'
                }
                this.url.list = '/hc/hcRecycleBagcode/queryListByStatus';
                this.visible = true
                if (cus && cus.customerNumber) {
                    this.queryParam.recycleBagStatus = 1;
                    this.queryParam.submitState = 1;
                    this.queryParam.customerNumber = cus.customerNumber;
                    this.loadData(1)
                }
            },
            close() {
                this.$emit('close')
                this.visible = false
            },
            handleOk() {
                this.close()
            },
            handleCancel() {
                this.close()
            },
            handleEdit() {

            }
        }
    }
</script>
<style scoped>
    @import '~@assets/less/common.less';
</style>
